package cn.bdqn.activity04;

import android.content.Intent;
import android.net.Uri;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {
 private Button btnTel,btnMsg,btnMap;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        btnTel=findViewById(R.id.btn_tel);
        btnMap=findViewById(R.id.btn_map);
        btnMsg=findViewById(R.id.btn_msg);

    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.btn_tel:
                Uri uri=Uri.parse("tel:10010");
                //两种方式，一种是拨打电话的，一种是跳到拨打电话的程序
                //Intent intent=new Intent(Intent.ACTION_DIAL,uri);
                Intent intent=new Intent(Intent.ACTION_CALL,uri);
                //第二种方式要进行授权
                startActivity(intent);
                break;
            case R.id.btn_map:
                Uri uri2=Uri.parse("geo:113.66455078,34.75063981");
                Intent intent2=new Intent(Intent.ACTION_VIEW,uri2);
                startActivity(intent2);
                break;
            case R.id.btn_msg:
                Uri uri3=Uri.parse("smsto:10086");
                Intent intent3=new Intent(Intent.ACTION_SEND,uri3);
                intent3.putExtra("sms_body","这一条短信");
                //需要设置权限
                break;
            default:break;

        }
    }
}
